<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>

</head>

<body>

    <div id="app">

        <!-- 计算属性 -->
        <span>一共有{{booksNum}}本书</span>

        <!-- 调用方法 -->
        <p>一共有{{booksFun()}}本书</p>
    </div>
</body>

<script>
    const { createApp } = Vue

    const vm = createApp({
        data() {
            return {
                message: '',
                obj: {
                    name: '张三',
                    books: ['钢铁是怎样炼成的', 'JavaScript高级程序设计', '初始渐进式开发']
                }
            }
        },
        // 计算属性
        computed: {
            booksNum(){
                return this.obj.books.length
            }
        },
        // 方法
        methods: {
            booksFun(){
                return this.obj.books.length
            }
        }
    }).mount('#app')


</script>

</html>